home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-02-24 | 1.5 KB | 68 lines | [TEXT/PJMM] |
- unit MyTrackIdle;
-
- { This code is part of the Finger/Fingerd source code, written in THINK Pascal 4 }
- { Copyright 1991-1992 Peter N Lewis }
- { If you use this code, you must give me credit in your about box and documentation }
- { This is part of my generic library of routines }
-
- interface
-
- function IdleSince: longInt; {TickCount at last no idle time}
- procedure InitTrackIdle;
- procedure FinishTrackIdle;
- procedure TrackIdle;
-
- implementation
-
- type
- keyLongMap = array[1..4] of longInt;
-
- var
- lastmoved: longInt; { Last time the cursor was moved, used for idle timing }
- lastpos: point;
- lastkeymap: keyLongMap;
-
- function IdleSince: longInt; {TickCount at last no idle time}
- begin
- IdleSince := lastmoved;
- end;
-
- procedure MyGetMouse (var pt: point); { Handles not having quickdraw around }
- var
- mousep: ^point;
- begin
- mousep := POINTER($830);
- pt := mousep^;
- end;
-
- procedure TrackIdle;
- var
- pt: point;
- km: keyLongMap;
- begin
- pt := lastpos;
- MyGetMouse(lastpos);
- if (abs(pt.h - lastpos.h) > 2) or (abs(pt.v - lastpos.v) > 2) then begin
- lastmoved := TickCount;
- end
- else begin
- GetKeys(keyMap(km));
- if (km[1] <> lastkeymap[1]) or (km[2] <> lastkeymap[2]) or (km[3] <> lastkeymap[3]) or (km[4] <> lastkeymap[4]) then begin
- lastmoved := TickCount;
- lastkeymap := km;
- end;
- end;
- end;
-
- procedure InitTrackIdle;
- begin
- MyGetMouse(lastpos);
- lastmoved := TickCount;
- GetKeys(keyMap(lastkeymap));
- end;
-
- procedure FinishTrackIdle;
- begin
- end;
-
- end.